package server;

import com.github.hwangrq.minicat.server.Request;
import com.github.hwangrq.minicat.server.Response;
import com.github.hwangrq.minicat.servlet.HttpServlet;
import com.github.hwangrq.minicat.utils.HttpProtocolUtil;

import java.io.IOException;

/**
 * @author hwangrq
 * @date 2021/3/17 17:39
 * @description
 */
public class TwoServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>TwoServlet GET</h1>";
        try {
            Thread.sleep(10000);
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>TwoServlet POST</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }
}
